﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Collections.Specialized;


namespace GestorDeFlotasDesktop.Login
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }
        private void Login_Load(object sender, EventArgs e)
        {
            
        }
      
        private bool tbNombreUsuario_Validated(object sender, EventArgs e)
        {
            if ("".Equals(tbNombreUsuario.Text))
            {
                this.errpLogin.SetError(tbNombreUsuario, "Campo obligatorio");
                return false;
            }
            Validator.TextValidator txValidator = new Validator.TextValidator();
            
            txValidator.PropertiesRegex = "loginUsuarioValidator";
            if(!txValidator.Validate(tbNombreUsuario.Text))
            {
                this.errpLogin.SetError(tbNombreUsuario, "Campo Alfanumerico");
                return false;
            }
             
            return true;
        }
        private bool tbPassword_Validated(object sender, EventArgs e)
        {
            if ("".Equals(tbPassword.Text))
            {
                this.errpLogin.SetError(tbPassword, "Campo obligatorio");
                return false;
            }
            Validator.TextValidator txValidator = new Validator.TextValidator();
            /*
            txValidator.PropertiesRegex = "loginPasswordValidator";
            if(!txValidator.Validate(tbPassword.Text))
            {
                this.errpLogin.SetError(tbPassword, "Campo Alfanumerico");
                return false;
            }
             */
            return true;
        }

        private void btSend_Click(object sender, EventArgs e)
        {
            this.errpLogin.Clear();
            if (tbNombreUsuario_Validated(sender, e) & tbPassword_Validated(sender, e))
            {
                return;
            }
            return;
        }
        private void btCancel_Click(object sender, EventArgs e)
        {
            this.Close();     
        }

        

       
    }      
}
